package org.yuankan.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.yuankan.entity.user;
import org.yuankan.service.UserService;

import java.util.List;

@RequestMapping("/method")
@RestController
public class UserController {

    @Autowired
    UserService userService;

//    private Logger logger = LoggerFactory.getLogger(this.getClass());
    /*查询全部*/
    @RequestMapping(value = "a1",method = RequestMethod.GET)
    public List<user> all(){
        return userService.findAll();
    }


    @GetMapping(value = "/user/{id}")
    public  user allId(@PathVariable("id") Integer id){
       user users = userService.getAllId(id);
//       logger.info("获取的详细信息:============="+users);

        System.out.println("获取的详细信息:============="+users);
       return users;
    }


    @GetMapping("/hello")
    public String sayHello() throws InterruptedException {
        // 模拟延迟或异常
        Thread.sleep(3000);  // 模拟 3 秒延迟
        return "Hello from server:";
    }
}
